﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ThongTinTaiKhoan : System.Web.UI.Page
{
    //DataBaseDataContext db = new DataBaseDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
       /* if (!IsPostBack)
        {
            if (Session["DangNhap"] == null)
                Response.Redirect("TrangChu.aspx");

            tbl_InformationCustomer InCr = db.tbl_InformationCustomers.SingleOrDefault(i => i.ID.ToString() == Session["DangNhap"]);
            if (InCr != null)
            {
                txtMail.Text = InCr.Email;
                txthoten.Text = InCr.Name;
                txtngaysinh.Text = string.Format("{0:dd/MM/yyyy}", InCr.Birthday);
                drlGioiTinh.SelectedValue = InCr.gender.ToString();
                txtdiachi.Text = InCr.address;
                txtdienthoai.Text = InCr.tel;
                txtcongty.Text = InCr.Companyname;
                txtdiachicongty.Text = InCr.CompanyAddress;
                txtDTcongty.Text = InCr.CompanyTel;
                txtFax.Text = InCr.Companyfax;


            }
        }

    }
    protected void btcapnhat_Click(object sender, EventArgs e)
    {
        var kt = db.tbl_InformationCustomers.Where(c => c.ID.ToString() != Session["DangNhap"] && c.Email == txtMail.Text);
        if (kt.Count() > 0)
        {
            lbThongBaoEmal.Visible = true;
            lbThongBaoEmal.Text = "Email đã được đăng ký";
        }
        else
        {
            lbThongBaoEmal.Visible = false;
            var Customers = db.tbl_InformationCustomers.SingleOrDefault(c => c.ID.ToString() == Session["DangNhap"]);
            if (Customers != null)
            {
                Customers.Name = txthoten.Text;
                System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("vi-VN");
                culture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy hh:mm";
                Customers.Birthday = DateTime.Parse(txtngaysinh.Text, culture);
                Customers.address = txtdiachi.Text;
                Customers.tel = txtdienthoai.Text;
                Customers.Companyname = txtcongty.Text;
                Customers.CompanyAddress = txtdiachicongty.Text;
                Customers.CompanyTel = txtDTcongty.Text;
                Customers.Companyfax = txtFax.Text;
                db.SubmitChanges();

            }
        }*/
    }
}